set(OTEL_LIB otel)

file(GLOB_RECURSE SOURCES "*.cpp")

if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
    add_definitions(-DBUILD_TYPE=10)
endif()
add_definitions(-DOPENTELEMETRY_ABI_VERSION_NO=2)
add_definitions(-DBUILD_TYPE_DT=10)
add_library(${OTEL_LIB} SHARED ${SOURCES})

if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
    target_include_directories(${OTEL_LIB}
        PUBLIC ${LUACLIB_SRC_DIR}/otel
        PUBLIC ${CONAN_INCLUDE_DIRS}
        PUBLIC ${CONAN_LIBS_OPENTELEMETRY}
    )

    target_link_libraries(${OTEL_LIB}
        PUBLIC ${CONAN_LIBS_OPENTELEMETRY}
        PUBLIC logging
        PUBLIC ${CONAN_LIBS_JSON}
    )
else()
    target_include_directories(${OTEL_LIB}
        PUBLIC ${LUACLIB_SRC_DIR}/otel
        PUBLIC ${PROTOBUF_INCLUDE_DIRS}
        PUBLIC ${GRPC_INCLUDE_DIRS}
    )

    target_link_libraries(${OTEL_LIB}
        PUBLIC opentelemetry::opentelemetry
        PUBLIC liblogger::liblogger
        PUBLIC skynet::skynet
        PUBLIC json::json
    )
endif()

set_target_properties(${OTEL_LIB} PROPERTIES PREFIX "")
install(TARGETS ${OTEL_LIB} DESTINATION opt/bmc/luaclib)